/*
 * Copyright (c) 2024. Shanghai HEADING information Engineering Co., Ltd. All rights reserved.
 */
package com.lovely602.design.study.basic;

/**
 * @author lizhixing
 */
public class StringTest {

  public static void main(String[] args) {

    String test = "test";

    String str = new String("test");
    System.out.println("str == test：" + (str == test));
    System.out.println("str.equals(test)：" + str.equals(test));

    String[] strArr = { "test", "test" };
    System.out.println("strArr.length：" + strArr.length);
    System.out.println("String.length()：" + test.length());

    System.out.println("test.indexOf(s)：" + test.indexOf("s"));
    System.out.println("test.charAt(2)：" + test.charAt(2));

    String replaceTest = test.replace("t", "T");
    System.out.println("replaceTest：" + replaceTest);
    String replaceAllTest = test.replaceAll("te", "T");
    System.out.println("replaceAllTest：" + replaceAllTest);
    System.out.println("test：" + test);

    System.out.println("trim：" + test.trim());

    println(test.split("/"));
    System.out.println("test.toLowerCase()：" + test.toLowerCase());
    System.out.println("test.toUpperCase()：" + test.toUpperCase());

    System.out.println("test.substring(1)：" + test.substring(1, 4));
    System.out.println("test.concat(test)：" + test.concat(test));
    System.out.println("test.hashCode()：" + test.hashCode());
  }

  private static void println(String[] args) {

    if (args == null || args.length == 0) {
      return;
    }

    for (String str : args) {
      System.out.print(str);
    }

  }
}
